﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using SEO.Business;
using SEO.Entity;

/// <summary>
/// Until 的摘要说明
/// </summary>
public class Until
{
    /// <summary>
    /// 注册提示脚本
    /// </summary>
    /// <param name="strAlert">提示内容</param>
    /// <returns></returns>
    public static void Alert(string strAlert)
    {
        Page p = (Page)System.Web.HttpContext.Current.Handler;
        p.ClientScript.RegisterStartupScript(p.GetType(), "", "alert('" + strAlert + "');", true);
    }

    /// <summary>
    /// 注册提示脚本
    /// </summary>
    /// <param name="strAlert">提示内容</param>
    /// <param name="strURL">返回页</param>
    /// <returns></returns>
    public static void Alert(string strAlert, string strURL)
    {
        Page p = (Page)System.Web.HttpContext.Current.Handler;
        p.ClientScript.RegisterStartupScript(p.GetType(), "", "alert('" + strAlert + "');location.replace('" + strURL + "');", true);
    }

    /// <summary>
    /// 注册提示脚本
    /// </summary>
    /// <param name="strAlert">提示内容</param>
    /// <param name="strURL">返回页</param>
    /// <returns></returns>
    public static void AlertJS(string strAlert, string strJS)
    {
        Page p = (Page)System.Web.HttpContext.Current.Handler;
        p.ClientScript.RegisterStartupScript(p.GetType(), "", "alert('" + strAlert + "');" + strJS, true);
    }
    /// <summary>
    /// 注册提示脚本
    /// </summary>
    /// <param name="strAlert">提示内容</param>
    /// <param name="strURL">返回页</param>
    /// <returns></returns>
    public static void AlertBefaultJS(string strAlert, string strJS)
    {
        Page p = (Page)System.Web.HttpContext.Current.Handler;
        p.ClientScript.RegisterStartupScript(p.GetType(), "", strJS + "alert('" + strAlert + "');", true);
    }

    /// <summary>
    /// 验证文件类型
    /// </summary>
    /// <param name="nType">类型(0:图片,1:文档)</param>
    /// <param name="extension">文件后缀</param>
    /// <returns></returns>
    public static bool CheckFileType(int nType, string strExtension)
    {
        string[] filetype;
        if (nType == 0)
        {
            //图片
            filetype = new string[] { ".jpg", ".png", ".gif", ".jpeg", ".bmp" };
        }
        else
        {
            //文档
            filetype = new string[] { ".doc", ".rar", ".zip", ".txt", ".xls" };
        }
        foreach (string strType in filetype)
        {
            if (strType == strExtension)
            {
                return true;
            }
        }
        return false;
    }

    /// <summary>
    /// 删除文件
    /// </summary>
    /// <param name="strFilePlace">文字路径</param>
    /// <returns></returns>
    public static bool DeleteFile(string strFilePlace)
    {
        try
        {
            if (File.Exists(strFilePlace))
            {
                File.Delete(strFilePlace);
            }
        }
        catch
        {
            return false;
        }
        return true;
    }



    /// <summary>
    /// 创建新的表
    /// </summary>
    /// <returns></returns>
    public static DataTable CreateNewDT(DataTable dt, DataRow[] drList)
    {
        DataTable dtNew = dt.Clone();
        foreach (DataRow dr in drList)
        {
            DataRow drTem = dtNew.NewRow();
            foreach (DataColumn column in dt.Columns)
            {
                drTem[column.ColumnName] = dr[column.ColumnName];
            }
            dtNew.Rows.Add(drTem);
        }
        return dtNew;
    }

}

/// <summary>
/// 权限记录表
/// </summary>
public class AdminFEATURE
{

    #region SEO收录情况
    /// <summary>
    /// 关键字排名
    /// </summary>
    public static readonly long KeywordsSEO = 0x2;

    /// <summary>
    /// 网编文章
    /// </summary>
    public static readonly long ArticleSEO = 0x4;

    /// <summary>
    /// 新闻源分析列表
    /// </summary>
    public static readonly long NewsWebSEOList = 0x20000;

    /// <summary>
    /// 新闻源分析操作
    /// </summary>
    public static readonly long NewsWebSEO = 0x40000;

    #endregion

    #region SEO配置

    /// <summary>
    /// 关键字分类列表
    /// </summary>
    public static readonly long Sort = 0x8;

    /// <summary>
    /// 关键字列表
    /// </summary>
    public static readonly long KeywordsList = 0x10;

    /// <summary>
    /// 今日关键字列表
    /// </summary>
    public static readonly long TodayKeywordsList = 0x8000;

    /// <summary>
    /// 医院名称列表
    /// </summary>
    public static readonly long MedicalList = 0x20;

    /// <summary>
    /// 新闻源列表
    /// </summary>
    public static readonly long NewsWebList = 0x40;

    /// <summary>
    /// 站内列表
    /// </summary>
    public static readonly long OurWebList = 0x1000;

    /// <summary>
    /// 特殊提成网站
    /// </summary>
    public static readonly long DeductWebList = 0x2000;

    /// <summary>
    /// 爬虫过滤网站
    /// </summary>
    public static readonly long FilterWebList = 0x200000;

    #endregion

    #region 用户管理
    /// <summary>
    /// 权限组列表
    /// </summary>
    public static readonly long UserType = 0x80;

    /// <summary>
    /// 用户列表
    /// </summary>
    public static readonly long UserList = 0x100;
    #endregion

    #region 其他管理

    /// <summary>
    /// 公告管理
    /// </summary>
    public static readonly long NoticeList = 0x100000;

    /// <summary>
    /// 系统配置
    /// </summary>
    public static readonly long SysConfig = 0x200;

    /// <summary>
    /// 抓虫运行情况
    /// </summary>
    public static readonly long SysRunLogList = 0x4000;

    /// <summary>
    /// 修改密码
    /// </summary>
    public static readonly long EditPassword = 0x400;
    #endregion

    #region 统计管理

    /// <summary>
    /// 关键字统计
    /// </summary>
    public static readonly long KeywordsReport = 0x10000;

    /// <summary>
    /// 关键字优化量统计
    /// </summary>
    public static readonly long ArticleTypeReportList = 0x400000;

    /// <summary>
    /// 文章提成统计
    /// </summary>
    public static readonly long ArticleReport = 0x800;

    /// <summary>
    /// 文章收录统计
    /// </summary>
    public static readonly long UserArticleReportList = 0x80000;
    #endregion
}

